package org.arnetminer.personalized.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class KeywordAnalyzer {

	public static Map<String, List<String>> analyzeUserKeyword(String keyword) {
		Map<String, List<String>> map = new HashMap<String, List<String>>();

		List<String> properties = new ArrayList<String>();
		List<String> values = new ArrayList<String>();

		if (keyword.indexOf(',') >= 0) {
			String[] parts = keyword.split(",");
			properties.add("lastName");
			values.add(parts[0].trim());

			if (parts.length > 1) {
				properties.add("firstName");
				values.add(parts[1].trim());
			}
		} else {
			keyword = keyword.replaceAll("  ", " ");
			String[] parts = keyword.split(" ");
			properties.add("firstName");
			values.add(parts[0].trim());
			if (parts.length > 1) {
				properties.add("lastName");
				values.add(parts[1].trim());
			}
		}
		map.put("properties", properties);
		map.put("values", values);
		return map;
	}
}
